import { PageHeader } from 'antd';
import { Button, Form, Input, Radio, Row, Col, message } from 'antd';
import { useState } from 'react';
import { useNavigate } from 'react-router';
import './index.scss'

import { addUserLable } from '../../../../../api/WL/userLable'

const routes = [
    {
        path: 'index',
        breadcrumbName: '用户管理',
    },
    {
        path: 'first',
        breadcrumbName: '用户标签',
    },
    {
        path: 'second',
        breadcrumbName: '新建用户标签',
    },
];
const Add_memberinterests = () => {
    const navigate = useNavigate();
    const [form] = Form.useForm();

    const submitForm = () => {
        console.log(form.getFieldsValue());
        let data = form.getFieldsValue();
        addUserLable(data).then((b) => {
            console.log(b);
            if (b.code === 200) {
                message.success('提交成功！');
                navigate('/home/user/userLable')
            }
        })
    }
    const goback = () => {
        navigate('/home/user/userLable')
    }

    return <div className='Add_memberinterests'>
        <PageHeader
            className="site-page-header"
            title="新建标签"
            breadcrumb={{
                routes,
            }}

        />
        <div className='content_editor clear' >
            <div className='left'>
                <Form
                    form={form}
                    name="basic"
                    labelCol={{
                        span: 6,
                    }}
                    wrapperCol={{
                        span: 10,
                    }}
                    initialValues={{
                        labelType: 0
                    }}
                    autoComplete="off"
                >
                    <Form.Item
                        label="标签名称"
                        name="labelName"
                    >
                        <Input />
                    </Form.Item>
                    <Form.Item
                        label="标签类型"
                        name="labelType"
                    >
                        <Radio.Group name="radiogroup">
                            <Row style={{ marginBottom: '20px' }}>
                                <Col>
                                    <Radio value={1}>手动标签</Radio>&nbsp;&nbsp;&nbsp;
                                    <Radio value={0}>自动标签</Radio>
                                </Col>
                            </Row>
                        </Radio.Group>
                    </Form.Item>
                    <Form.Item
                        wrapperCol={{
                            offset: 8,
                            span: 16,
                        }}
                    >
                        <Button type="primary" onClick={submitForm}>
                            提交
                        </Button>
                        &nbsp; &nbsp; &nbsp;
                        <Button htmlType="submit" onClick={goback}>
                            返回
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        </div>
    </div>
}
export default Add_memberinterests